package com.emm.yixun.mobile.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.emm.yixun.mobile.R;
import com.emm.yixun.mobile.model.GetAuditList;

public class ToExamineAdapter extends BaseAdapter {
	Context context;

	GetAuditList date;

	public ToExamineAdapter(Context context, GetAuditList date) {
		this.context = context;
		this.date = date;
	}

	public void SetDateNotify(GetAuditList date) {
		this.date = date;
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		return date.getAuditList() == null ? 0 : date.getAuditList().size();
	}

	@Override
	public Object getItem(int position) {
		return date.getAuditList() == null ? null : date.getAuditList().get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHoudlers v = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(R.layout.to_examine_item, null);
			v = new ViewHoudlers();
			v.contents_name = (TextView) convertView.findViewById(R.id.contents_name);
			v.time_to_examine = (TextView) convertView.findViewById(R.id.time_to_examine);
			v.title = (TextView) convertView.findViewById(R.id.title);
			v.type = (TextView) convertView.findViewById(R.id.type);
			convertView.setTag(v);
		} else {
			v = (ViewHoudlers) convertView.getTag();
		}
		if ("认购".equals(date.getAuditList().get(position).getAuditType().trim())) {
			v.type.setBackgroundResource(R.drawable.mode_loock_type2);
		} else if ("认筹".equals(date.getAuditList().get(position).getAuditType().trim())) {
			v.type.setBackgroundResource(R.drawable.mode_loock_type);
		} else if ("签约".equals(date.getAuditList().get(position).getAuditType().trim())) {
			v.type.setBackgroundResource(R.drawable.mode_loock_type3);
		} else {
			v.type.setBackgroundResource(R.drawable.mode_loock_type);
		}
		v.contents_name.setText(date.getAuditList().get(position).getAgent());
		v.time_to_examine.setText(date.getAuditList().get(position).getCreateTime());
		v.title.setText(date.getAuditList().get(position).getHouses());
		v.type.setText(date.getAuditList().get(position).getAuditType());
		return convertView;
	}

	public static class ViewHoudlers {
		TextView title, type, contents_name, time_to_examine;

	}

}
